#MODIFY HERE
#corpus=/data/corpus/ek-all
corpus=/home/swlee4skmt/wta/corpus/ck-all
scripts=/home/swlee4skmt/svn_co/smt/copycat/exp/scripts
misc=/home/swlee4skmt/svn_co/smt/copycat/misc


########################################################
if [ $# == 3 ]; then
	echo -n ""
else
	echo "usage: ck-data-prepare.sh  [cr|rf]  [st|int|uni]  number(k)"
	exit
fi


type=$1
symm=$2
label=$3

eval=1000
dev=1000
let train=label*1000
let all=eval+dev+train
let eval_dev=eval+dev
let eval_train=eval+train


########################################################
echo "Evaluation: " $eval
echo "Development:" $dev
echo "Training:   " $train


#### start automatic generation
dir=_ck-${type}-${symm}-${label}k
echo Creating $dir
rm -rf $dir; mkdir -p $dir;
cd $dir

##### running file
ln -s ${scripts}/run-all.sh .
ln -s ${scripts}/run-smt.sh .

##### INFO
echo Making info
mkdir info
cd info
ln -s $corpus/wa-gold.gui.giza  wa-gold.ans
ln -s $corpus/wa-gold.num  wa-gold.num
echo ${eval} > num-eval.var
echo ${dev} > num-dev.var
echo ${train} > num-train.var
echo ${type} > rule_type.var
echo ${symm} > symm.var
cd ..

##### Init
echo Making Init 
mkdir i0; cd i0;
ln -s ${scripts}/copycat.sh .
ln -s ${scripts}/copycat-train.sh .
ln -s ${scripts}/make-next.sh .
echo 0 > now-itr.var

### corpus
echo Making corpus 
mkdir corpus; cd corpus;
head -${eval} $corpus/cn.SP > src-eval.SP
tail -${dev}  $corpus/cn.SP > src-dev.SP
head -${eval_train} $corpus/cn.SP | tail -${train} > src-train.SP
cat src-eval.SP src-dev.SP src-train.SP > src-all.SP

head -${eval} $corpus/cn.parse > src-eval.parse
tail -${dev} $corpus/cn.parse > src-dev.parse
head -${eval_train} $corpus/cn.parse | tail -${train} > src-train.parse
cat src-eval.parse src-dev.parse src-train.parse > src-all.parse

head -${eval} $corpus/kr.SP > tgt-eval.SP
tail -${dev} $corpus/kr.SP > tgt-dev.SP
head -${eval_train} $corpus/kr.SP | tail -${train} > tgt-train.SP
cat tgt-eval.SP tgt-dev.SP tgt-train.SP > tgt-all.SP
cd ..

### WA
echo Making wa
mkdir wa; cd wa;
ln -s ../corpus/src-all.SP src.SP
ln -s ../corpus/tgt-all.SP tgt.SP
ln -s ${scripts}/run-giza.sh .
ln -s ${scripts}/eval.sh .
ln -s ${misc}/giza_st.cfg .
ln -s ${misc}/giza_ts.cfg .
cd ..;

# SMT data
echo Making smt
mkdir smt; cd smt;
cat ${scripts}/Makefile | sed s/VARIABLE/ek-${type}-${symm}-${label}/ > Makefile
ln -s ../corpus/src-eval.SP ./src-eval.utf8
ln -s ../corpus/src-dev.SP ./src-dev.utf8
ln -s ../corpus/src-train.SP ./src-train.utf8
ln -s ../corpus/tgt-eval.SP ./tgt-eval.utf8
ln -s ../corpus/tgt-dev.SP ./tgt-dev.utf8
ln -s ../corpus/tgt-train.SP ./tgt-train.utf8
cd ..;

cd ..;
echo Done

